/*
 * Texture.h
 *
 *  Created on: 23 mai 2011
 *      Author: seeme
 */

//Une texture à 1 ou N dimensions
//Source chargement de fichier png : David Henry @ developpez.com
#ifndef TEXTURE_H_
#define TEXTURE_H_

#include "../Resource.h"
#include <GL/glew.h>
#include <png.h>

class Texture: public Resource{
private:

	/* OpenGL texture info */
	typedef struct{
		GLsizei width;
		GLsizei height;

		GLenum format;
		GLint internalFormat;
		GLuint id;

		GLubyte *texels;

	} gl_texture_t;

	GLuint m_textureId;
	GLuint loadFromFile(std::string filepath);
	gl_texture_t *	ReadPNGFromFile (std::string filename);
	void GetPNGtextureInfo (int color_type, gl_texture_t *texinfo);
	GLuint m_type;

public:
	Texture(std::string name, std::string path): Resource(name, path), m_type(GL_TEXTURE_2D){}

	size_t getSize(){return m_size;};

	bool create();
	void destroy();

	GLuint getId(){return m_textureId;}
};
#endif /* TEXTURE_H_ */
